<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1,user-scalable=no">
    <title>将图层添加到3D场景</title>
    <style>
        html,body,#viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }
    </style>
    <link rel="stylesheet" href="https://js.arcgis.com/4.17/esri/css/main.css">
    <script src="https://js.arcgis.com/4.17/"></script>
    <script>
        // 转到每个托管的要素服务URL端点以了解有关元数据，数据和所支持功能的更多信息
        // 每个链接将显示图层类型，几何类型，范围，工程图信息，字段等
        // 在每个页面的底部查找“支持的选项”，然后尝试使用查询功能在每个数据集中查找并返回记录
        // 一个FeatureLayer在后台使用这些函数来获取数据，并绘制在地图上
        require([
            'esri/Map',
            'esri/views/SceneView',
            'esri/layers/FeatureLayer'
        ],function(
            Map,
            secneView,
            FeatureLayer
        ) {
            var map = new Map({
                basemap:"topo-vector",
                ground:"world-elevation"
            });

            var view = new secneView({
                container:"viewDiv",
                map:map,
                camera:{
                    position: {
                        x: -118.808,
                        y: 33.961,
                        z: 2000  // meters
                    },
                    tilt:75  // 倾斜角度
                },
            });

            // 添加要素图层

            // Trails feature layer (lines)
            var trailsLayer = new FeatureLayer({
                url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0",
                //*** ADD ***//
                // 筛选
                definitionExpression: "ELEV_GAIN < 250",

                //*** ADD ***//
                // 渲染
                renderer: {
                    type: "simple",
                    symbol: {
                        type: "simple-line",
                        color: "green",
                        width: "2px"
                    }
                },

                //*** ADD ***//
                // 输出内容
                outFields: ["TRL_NAME", "ELEV_GAIN"],

                //*** ADD ***//
                // 弹框模板
                popupTemplate: {
                    // Enable a popup
                    title: "{TRL_NAME}", // Show attribute value
                    content: "The trail elevation gain is {ELEV_GAIN} ft." // Display text in pop-up
                }
            });
            map.add(trailsLayer, 0);

        })
    </script>
</head>
<body>
    <div id="viewDiv"></div>
</body>
</html>